Repository navigation
HDDS-16654. Replace usage of deprecated finalize() in OM - #11376
Conversation
chihsuan
left a comment
There was a problem hiding this comment.
Thanks for working on this! @anuragp010 Looks good overall, just two small notes. 👍
| * opened; this exercises the constructor's LeakDetector registration and the GC-triggered report. | ||
| */ | ||
| @Test | ||
| void leakDetectedForUnclosedSnapshot() throws Exception { |
There was a problem hiding this comment.
Should we also add a test for the closed case? Right now the tests still pass even without leakTracker.close().
There was a problem hiding this comment.
Thanks @chihsuan ! Yes that's a good point. I have added it.
| // Close DB | ||
| omMetadataManager.getStore().close(); | ||
| // Closed properly: stop tracking so the leak reporter does not fire at GC. | ||
| leakTracker.close(); |
There was a problem hiding this comment.
nit: Could we use try/finally here, like OzoneClient#close? That way the tracker is still released if the store close throws.
There was a problem hiding this comment.
Makes sense - have added it.
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @anuragp010 for the patch.
| return () -> { | ||
| if (!store.isClosed()) { | ||
| // Print hash code for debugging | ||
| LOG.warn("{} is not closed properly. snapshotName: {}", store, snapshotName); | ||
| } | ||
| }; |
There was a problem hiding this comment.
I don't think we should keep a strong reference to store in the leak reporter.
- I think checking
store.isClosed()is unnecessary.LeakTrackerdiscards properly closed instances and will not call the reporter. - For "print hash code for debugging", we should get that eagerly and keep reference only to the string to be included in the message.
There was a problem hiding this comment.
Thanks @adoroszlai ! Right, makes sense. I have addressed this.
chihsuan
left a comment
There was a problem hiding this comment.
Thanks for the updates! @anuragp010 LGTM +1, just two small nits.
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
|
Thanks @anuragp010 for the patch, @chihsuan for the review. |
|
Thanks @chihsuan and @adoroszlai ! |
* master: (64 commits) HDDS-16716. Add description for ozone.scm.ec.pipeline.per.volume.factor (#11415) HDDS-16008. PutBlocks from Flushes also go without Raft (#11356) HDDS-16666. Flush SCM transaction in memory during apply transaction (#11409) HDDS-15749. Run specific JUnit tests if possible (#10671) HDDS-16362. GetObjectAttributes ObjectParts should return Part entries for FSO buckets (#11242). HDDS-16643. Remove CleanupTableInfo mechanism (#11365) HDDS-16721. StreamBlockInputStream.read() returns a negative value for bytes 0x80 to 0xFF (#11411) HDDS-16241. gRPC deadline kills long-lived block streams after 30 seconds and the client never recovers (#11080) HDDS-15991. Speed up deleted table scans in quota repair (#11386) HDDS-16674. Bump awssdk to 2.55.6 (#11407) HDDS-16673. Avoid redundant ListBuckets RPCs when S3 bucket listing reaches the end (#11397) HDDS-16708. Let dependabot ignore iceberg minor version upgrades (#11398) HDDS-16713. Bump develocity-maven-extension to 2.6.0 (#11405) HDDS-16300. Allow OM to dynamically reconfigure its SCM node list without a restart (#11218) HDDS-15089. Support S3 per request read consistency (#11252) HDDS-16704. ReadBlock fails with IllegalStateException when a response is shorter than responseDataSize (#11402) HDDS-16631. Fix chooseRandom for rack names with common prefixes (#11401) HDDS-16654. Replace usage of deprecated finalize() in OM (#11376) HDDS-16658. Reuse source key details when opening input stream in S3 CopyObject (#11396) HDDS-16711. Bump moment to 2.31.0 (#11373) ... Conflicts: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/HealthyReadOnlyNodeHandler.java hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeStateManager.java hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestSCMStateMachine.java hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestDeadNodeHandler.java hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestNodeStateManager.java hadoop-ozone/client/src/test/java/org/apache/hadoop/ozone/client/rpc/TestRpcClient.java hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/ha/TestHadoopRpcOMFollowerReadFailoverProxyProvider.java hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerStateMachine.java hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/upgrade/OMCancelPrepareResponse.java hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/upgrade/OMCompleteFinalizeUpgradeResponse.java hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/upgrade/OMPrepareResponse.java hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerRequestHandler.java hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerStateMachine.java
What changes were proposed in this pull request?
OmSnapshotoverrodeObject.finalize()to warn if itsDBStorewasn't closed before GC. Butfinalize()is deprecated for removal (JEP 421). This PR replaces it withLeakDetector, aReferenceQueue-based leak tracker, used in the same way byManagedRocksObjectUtils. A staticLEAK_DETECTORtracks eachOmSnapshotinstance viaLEAK_DETECTOR.track(this, reporter). If the instance is dropped unclosed, the detector's background thread reports the same warning the oldfinalize()did, once the object is actually collected.Generated with Claude Code.
What is the link to the Apache JIRA
HDDS-16654
How was this patch tested?